using Castle.MonoRail.Framework;
using Query;
using Rhino.Commons;
using WineCellar.Data;

namespace WineCellar.Web.Controllers
{
    [Layout("index"), Rescue("generalerror")]  
	public class HomeController : ApplicationController
	{
		[Resource("home","WineCellar.Web.Resources.Home")]
		public void Index()
		{
			
            if (IsAjaxRequest) { CancelLayout(); }
			PreProcess();
		}
		
       private void PreProcess()
        {            
           PropertyBag["wines"] = Repository<Wine>.FindAll(Where.Wine.AddedBy.IsNotNull,0, 5,OrderBy.Wine.DateAdded.Desc);        
        }
        public void SetLanguage(object id)
        {
            Response.CreateCookie("locale", (string)id);			
            RedirectToAction("index");
        }
	}
}

